<?xml version="1.0" encoding="UTF-8"?>


<!--
	special.inc.xsl

	Template per formattazione elementi speciali
-->


<xsl:stylesheet
	version = "1.0"
	xmlns = "http://www.w3.org/1999/xhtml"
	xmlns:inc = "http://ltw0807.web.cs.unibo.it/xsl/inc"
	xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">


	<!--
		Template logo
	-->
	<xsl:template match = "logo">
		<xsl:element name = "div">
			<xsl:call-template name = "inc:create-output-markers"/>

			<xsl:choose>
				<!-- Trasforma un a in un img assegnando un'alt standard. -->
				<xsl:when test = "./a">
					<xsl:element name = "img">
						<xsl:attribute name = "src">
							<xsl:value-of select = "./a/@href"/>
						</xsl:attribute>
						<xsl:attribute name = "alt">
							<xsl:text>Logo del gruppo.</xsl:text>
						</xsl:attribute>
					</xsl:element>
				</xsl:when>

				<!-- altrimenti ricopia -->
				<xsl:otherwise>
					<xsl:apply-templates/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:element>
	</xsl:template>


	<!--
		Template navigazione e opzioni come lista di liste trattate
		con CSS
	-->
	<xsl:template match = "navigazione | opzioni[child::ul]">
		<xsl:element name = "ul">
			<xsl:call-template name = "inc:create-output-markers"/>
			<xsl:apply-templates select = "ul/li"/>
		</xsl:element>
	</xsl:template>


	<!--
		Template opzioni standard come combo-box
	-->
	<xsl:template match = "opzioni[child::ul[@class = 'combo']]">
		<xsl:element name = "div">
			<xsl:call-template name = "inc:create-output-markers"/>
			<xsl:element name = "label">
				<xsl:attribute name = "for">
					<xsl:text>layout-skin-selector</xsl:text>
				</xsl:attribute>
				<xsl:text>Aspetto</xsl:text>
			</xsl:element>
			<xsl:element name = "select">
				<xsl:attribute name = "id">
					<xsl:text>layout-skin-selector</xsl:text>
				</xsl:attribute>
				<xsl:apply-templates select = "ul/li" mode = "combo"/>
			</xsl:element>
		</xsl:element>
	</xsl:template>

	<xsl:template match = "opzioni/ul/li" mode = "combo">
		<xsl:element name = "optgroup">
			<xsl:attribute name = "label">
				<xsl:value-of select = "text()"/>
			</xsl:attribute>
			<xsl:apply-templates select = "ul/li" mode = "combo"/>
		</xsl:element>
	</xsl:template>

	<xsl:template match = "opzioni/ul/li/ul/li" mode = "combo">
		<xsl:element name = "option">
			<xsl:call-template name = "inc:copy-js-attr"/>
			<xsl:apply-templates />
		</xsl:element>
	</xsl:template>

	<!--
		Template opzioni non standard
	-->
	<xsl:template match = "opzioni">
		<xsl:element name = "div">
			<xsl:call-template name = "inc:create-output-markers"/>
			<xsl:apply-templates/>
		</xsl:element>
	</xsl:template>


	<!--
		Template messaggio o info-pagina
	-->
	<xsl:template match = "messaggio | info-pagina">
		<xsl:element name = "div">
			<xsl:call-template name = "inc:create-output-markers"/>
			<xsl:apply-templates/>
		</xsl:element>
	</xsl:template>

</xsl:stylesheet>
